package uk.co.q3c.deplan.server.unit.domain.task;

import java.util.Date;

import uk.co.q3c.deplan.client.domain.resource.IndividualResource;
import uk.co.q3c.deplan.client.domain.resource.ResourceGroup;
import uk.co.q3c.deplan.client.domain.task.BaseTask;
import uk.co.q3c.deplan.server.unit.dao.LocalDatastoreTestCase;

public class DomainBase_UT extends LocalDatastoreTestCase {

	protected BaseTask createStandardTask(long id) {
		return createStandardTask(id, true);
	}

	protected BaseTask createStandardTask(long id, boolean setDates) {
		return createStandardTask(Long.toString(id), setDates);
	}

	protected BaseTask createStandardTask(String name) {
		return createStandardTask(name, true);
	}

	protected BaseTask createStandardTask(String name, boolean setDates) {
		BaseTask task = new BaseTask(connection);
		if (setDates) {
			task.setStartRemaining(new Date());
			task.setPlannedFinish(new Date());
		}
		task.setName(name);
		// task.setKeyId(id);
		// connection.taskService().getDag().
		task.save();
		return task;
	}

	protected BaseTask createProject(String name) {
		BaseTask project = new BaseTask(connection);
		project.setName(name);
		project.setProject();
		project.save();
		return project;
	}

	protected IndividualResource createResource(String name) {
		IndividualResource ir = new IndividualResource(connection);
		ir.setName(name);
		ir.save();
		return ir;
	}

	protected ResourceGroup createResourceGroup(String name) {
		ResourceGroup group = new ResourceGroup(connection);
		group.setName(name);
		group.save();
		return group;
	}

}
